﻿using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

namespace ClassGenerator.UnitTest
{
    [TestClass]
    public class SqlServerSMOTest
    {
        [TestMethod]
        public void SQL_SELECT_TEST()
        {
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(""))
                {
                    sqlConn.Open();

                    ServerConnection serverConn = new ServerConnection(sqlConn);

                    Server _server = new Server(serverConn);

                    _server.SetDefaultInitFields(typeof(Table), "IsSystemObject", "CreateDate");
                    _server.SetDefaultInitFields(typeof(StoredProcedure), "IsSystemObject", "CreateDate");
                    _server.SetDefaultInitFields(typeof(UserDefinedFunction), "IsSystemObject", "CreateDate", "FunctionType");
                    _server.SetDefaultInitFields(typeof(View), "IsSystemObject", "CreateDate");
                    _server.SetDefaultInitFields(typeof(Column), "Identity");
                    _server.SetDefaultInitFields(typeof(Index), "IndexKeyType");

                    foreach (NamedSmoObject smoObj in _server.Databases)
                    {

                    }

                    serverConn.Disconnect();
                    
                    Assert.IsTrue(true);

                }
            }
            catch (Exception ex)
            {
                Assert.IsFalse(true);
            }

        }
    }
}
